//
//  LBCommentPopController.m
//  TEXT
//
//  Created by mac on 2024/7/7.
//  Copyright © 2024 刘博. All rights reserved.
//

#import "LBCommentPopController.h"

#import "LBFunctionTestHeader.h"
#import "LBCommentPopView.h"

@interface LBCommentPopController () <UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) LBCommentPopView *commentPopView;

@property (nonatomic, strong) UIView *containerView;

@property (nonatomic, strong) UIView *headerView;

@property (nonatomic, strong) UITableView *commentListView;

@end

@implementation LBCommentPopController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.backgroundColor = [UIColor cyanColor];
    button.frame = CGRectMake(100, 100, 100, 100);
    [self.view addSubview:button];
    [button addTarget:self action:@selector(kkk) forControlEvents:UIControlEventTouchUpInside];
    // Do any additional setup after loading the view.
}

- (void)kkk
{
    [self.view addSubview:self.commentPopView];
    [self.commentPopView show:^{
            
    }];
}

#pragma mark - tableviewdelegate tableViewdatasource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 100;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])];
    cell.textLabel.text = [NSString stringWithFormat:@"%ld", indexPath.row];
    cell.textLabel.textColor = [UIColor cyanColor];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}

#pragma mark - lazy load

- (LBCommentPopView *)commentPopView
{
    if (!_commentPopView) {
        _commentPopView = [[LBCommentPopView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScreenHeight)];
        _commentPopView.containerView = self.containerView;
        [_commentPopView addSubview:self.containerView];
    }
    return _commentPopView;
}

- (UIView *)containerView {
    if (!_containerView) {
        _containerView = [[UIView alloc] initWithFrame:CGRectMake(0, ScreenHeight, ScreenWidth, ScreenHeight - 200 * rectScale())];
        _containerView.backgroundColor = [UIColor whiteColor];
        [_containerView addSubview:self.headerView];
        [_containerView addSubview:self.commentListView];
    }
    return _containerView;
}

- (UIView *)headerView
{
    if (!_headerView) {
        _headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 60 * rectScale())];
        _headerView.backgroundColor = [UIColor redColor];
    }
    return _headerView;
}

- (UITableView *)commentListView
{
    if (!_commentListView) {
        _commentListView = [[UITableView alloc] initWithFrame:CGRectMake(0, 60 * rectScale(), ScreenWidth, ScreenHeight - 260 * rectScale()) style:UITableViewStylePlain];
        [_commentListView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass([UITableViewCell class])];
        _commentListView.delegate = self;
        _commentListView.dataSource = self;
        _commentListView.backgroundColor = [UIColor whiteColor];
    }
    return _commentListView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
